package com.wy.springbootblog.pojo;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.wy.springbootblog.validate.loginGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;

@NoArgsConstructor
@AllArgsConstructor
@Data
@TableName("`user`")
public class User {
    @TableId
//    @NotNull
    private Integer id;

    @NotEmpty(message = "用户名不能为空", groups = loginGroup.class)
    @Pattern(regexp = "^\\S{5,16}$") // 5到16位非空字符
    private String username;

//    @JsonIgnore
    @NotEmpty(message = "密码不能为空", groups = loginGroup.class)
    @Pattern(regexp = "^\\S{5,16}$") // 5到16位非空字符
    private String password;

//    @NotEmpty
    private String role;  // admin、normal

//    @NotEmpty
    @Email
    private String email;

    private String avatar;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;
}
